-
Notifications
You must be signed in to change notification settings - Fork 10
Add context attribute to link TODOs to GitHub issues
#107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This PR introduces an optional `context` attribute for TODO comments that allows linking them to GitHub issues using the `issue()` function. This provides better traceability between code `TODO`s and their corresponding GitHub issues.
## Key Features
- **New `context` attribute**: Can be added to any `TODO` with an event trigger
- **`issue()` function**: Takes 3 parameters (org, repo, issue_number)
- **Rich context information**: When a `TODO` is triggered, the linked issue's title, state, and assignee are included in the notification
- **Works with all events**: Compatible with `date`, `gem_release`, `gem_bump`, and `ruby_version` events (not with `issue_close`/`pull_request_close` as they already reference issues/PRs)
## Example Usage
```ruby
# TODO(on: date('2025-02-01'), to: '[email protected]', context: issue('shopify', 'smart_todo', '108'))
# Implement the caching strategy discussed in the issue
```
## Implementation Details
- Context validation follows the same pattern as existing event validations
- The smart_todo_cop validates context syntax and arguments
- Context information is fetched only when the `TODO` event is triggered
- If the issue cannot be fetched, the `TODO` notification is still sent without context
Closes #108
🤖 Generated with Claude Code
issue_pin event to link TODOs with GitHub issuescontext attribute to link TODOs with GitHub issues
…nsidered valid with `issue_close` and `pull_request_close`
236b2b0 to
39ccf2b
Compare
Edouard-chin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a great addition, but I have the feeling that this may try to over-engineer a solution. It also makes a todo definition very verbose and it becomes hard to read when looking at the TODO definition.
I wonder if a more simpler approach à la GitHub would be easier.
# TODO(on...)
# Part of the bigger cleanup
# Ref Shopify/super_repo#34When SmartTodo detects the Ref ... part, it would transfom it to a link to be sent along the slack message
Co-authored-by: Rafael Mendonça França <[email protected]>
At the same time, I refactored to avoid code duplication and added tests Ref: #107 (comment)
Thanks for the feedback ! Using Given I believe it's better to build What do you think ? |
|
I understand that building a structured context makes it easier for us to parse. But it comes with the downside of making it harder for humans to write and read. Writing a smart todo is already not the most user friendly (especially since its just a comment without any syntax highlighting), and I'm worried that adding a new programming syntax info to the TODO will clutter it even more. Ultimately a TODO should be written to be read by humans not machines which is why I suggested the standard I wouldn't want to dismiss the great work you already put in this PR and since Rafael is also ok with this approach I'll defer to his approval. At the very minimum if we go with the structured context, please consider |
|
I actually really like |
…e complex construct that makes it harder for humans to process Refs: #107 (comment) and #107 (comment)
@rafaelfranca + @Edouard-chin I stacked #110 onto the current PR; for an easy diff of what it would look like. Let me know what you think |
Edouard-chin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the stacked PR in #110 (it looks nice). I made a few of suggestions here.
Add `context` attribute to link `TODO`s with GitHub issues (as string)
Addressed the received feedback; looks like the code is ready to be reviewed for a final pass (@Edouard-chin + @rafaelfranca ). I kept ed3d9f8 and 77ec138 laser-focused on the PR. |
Edouard-chin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this 👍 . I just have one last feedback https://github.com/Shopify/smart_todo/pull/107/files#r2472368783
context attribute to link TODOs with GitHub issuescontext attribute to link TODOs to GitHub issues
Super excited to contribute to this public repo ! After merge, what action(s) do I need to take so a new release is issued and I can use this new format in other repos ? |
|
You can cut a new release and deploy through our shipit stack to have the gem published on RubyGems. Shipit will take care of creating the git tag matching the bumped version. You may also want to create a Github release and add a few lines of doc introduce in the new version. |
Bring improvements from PR #107 I got interesting feedback for improvements in #107 In order to avoid feature-creep on my previous PR, I punted on touching files/methods outside the scope I was working on. This new PR brings improvements from ed3d9f8 and 77ec138 across the whole project. No functional change; simply adding consistency across files.
I couldn't find I ended up posting here: https://shopify.slack.com/archives/C2G36UR8B/p1761829568697519 |
|
I was pointed to https://shipit.shopify.io/shopify/smart_todo/rubygems to trigger the |
|
Awesome, thank you 👏. Not a big deal, but for next time it would be preferable to squash your commits before merging for a cleaner git history. |
This PR introduces an optional
contextattribute forTODOcomments that allows linking them to GitHub issues. This provides better traceability between codeTODOs and their corresponding GitHub issues.Key Features
contextattribute: Can be added to anyTODOwith an event triggerTODOis triggered, the linked issue's title, state, and assignee are included in the notificationdate,gem_release,gem_bump, andruby_versionevents -- andissue_close/pull_request_closetoo even if they already reference issues/PRs because thecontextcould provide more infoExample Usage
Implementation Details
TODOevent is triggeredTODOnotification is still sent without contextCloses #108
🤖 Generated with Claude Code